//Thread的几个常见属性
/* 
 * 1.getId(),表示ID
 * 2.getName(),表示名称
 * 3.getState(),表示状态
 * 4.getPriority(),表示优先级
 * 5.isAlive(),表示是否存活
 * 6.isInterrupted(),表示是否被中断
*/
public class Test_2_2 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                try {
                    System.out.println(Thread.currentThread().getName() + " " + i);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            System.out.println("线程结束");
        });

        System.out.println(Thread.currentThread().getName() + ": ID: " + t1.getId());
        System.out.println(Thread.currentThread().getName() + ": 名称: " + t1.getName());
        System.out.println(Thread.currentThread().getName() + ": 状态: " + t1.getState());
        System.out.println(Thread.currentThread().getName() + ": 优先级: " + t1.getPriority());
        System.out.println(Thread.currentThread().getName() + ": 后台线程: " + t1.isDaemon());
        System.out.println(Thread.currentThread().getName() + ": 活着: " + t1.isAlive());
        System.out.println(Thread.currentThread().getName() + ": 被中断: " + t1.isInterrupted());

        t1.start();

        while (t1.isAlive()) {
            System.out.println(Thread.currentThread().getName() + ": 状态: " + t1.getState());
        }

        
    }
}
